package cc.ufinity.networkdiagnose.view;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public class WelcomeActivity extends AbstractActivity {

	//private ProgressBar pbar;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.welcome);
		//pbar = (ProgressBar) this.findViewById(R.id.pBar);
		//注册服务
		//Intent service = new Intent(this,WifiScanService.class);
		//super.startService(service);
		init();
	}

	private void init() {
		//if (NetworkManager.detectNetworkConnectivity(this, 0)) {
			delay();
		/*} else {
			Toast.makeText(WelcomeActivity.this, "目前手机没有连接网络，请开启3G/2G或 WLAN网络",
					5000).show();

			// 设置扫描WLAN热点句柄,超时就停止扫描
			Handler wifiReceiverHandler = new Handler() {
				public void handleMessage(Message msg) {
					switch (msg.what) {
					case 1:
						// setScanTimout(true);
						pbar.setVisibility(View.GONE);
						Toast.makeText(WelcomeActivity.this,
								"附近没有WIFI网络热点，请选择其他地点重试或开启3G/2G！", 5000).show();
						break;
					}
					 super.handleMessage(msg);
				}
			};
			wlanManager = new WlanManager(this);
			wlanManager.setWifiReceiverHandler(wifiReceiverHandler);
			wlanManager.openWifi();
			wlanManager.startScan();
			wlanManager.startScanTimer();
		}*/
	}
	
	private void enter(){
		Intent main = new Intent(WelcomeActivity.this, MainActivity.class);
		startActivity(main);
		this.finish();
	}

	private void delay() {
		new Thread() {
			public void run() {
				try {
					Thread.sleep(3000);
					enter();
				} catch (InterruptedException e) {
					Log.e("Bootstrap", "Thread sleep exception:", e);
				}
			}
		}.start();
	}

}
